package com.apestech.framework.xml.sql.node;

import com.apestech.framework.json.JSONArray;
import com.apestech.framework.xml.plugin.modul.GridHead;
import com.apestech.framework.xml.pub.core.NodeJson;
import org.dom4j.Element;

/**
 * @author hup
 * @create 2018-12-14-9:44
 */
public class NodeHead {
    private Element node;
    private GridHead head;
    public NodeHead(Element node){
        this.node=node;
        this.head=new GridHead();
    }

    public void expain() throws Exception {
        NodeJson json=new NodeJson(node);
        json.expain();
        JSONArray result;
        if(json.getResult().get("fields") instanceof  JSONArray) result= (JSONArray) json.getResult().get("fields");
        else {
            result=new JSONArray();
            result.add(json.getResult().get("fields"));
        }
        head.addHead(result);
    }

    public GridHead getHead() {
        return head;
    }
}
